<template>
  <div class="leftnav">
    <div class="leftnav-title">
      <strong>
        <span class="icon-list"></span>功能列表
      </strong>
    </div>
    <el-menu default-active="2" class="el-menu-vertical-demo">
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-menu"></i>
          <span>管理</span>
        </template>
        <el-menu-item :index="'1-'+index" v-for="(menu,index) in menus" :key="index">
          <router-link :to="menu.link">{{menu.name}}</router-link>
        </el-menu-item>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title">
          <i class="el-icon-setting"></i>
          <span>个人中心</span>
        </template>
        <el-menu-item index="2-1">
          <router-link to="/changepwd">修改密码</router-link>
        </el-menu-item>
        <el-menu-item index="2-2">
          <router-link to="/logout">退出</router-link>
        </el-menu-item>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
import Axios from "axios";
import Global from "@/Global";
import Qs from "qs";
export default {
  data() {
    return {
      menus: [],
    };
  },
  mounted() {
    Axios.get("/tfss/admin/getMenuById").then((r) => {
      if (r.data.code == 200) {
        this.menus = r.data.data;
      } else if (r.data.code == 403) {
        this.$message.error("没有权限");
      } else if (r.data.code == 703) {
        this.$message.error("未登录");
      } else if (r.data.code == 500) {
        this.$message.error("系统繁忙，请稍后再试");
      } else if (r.data.code == 704) {
        this.$message.error("登录失效，请重新登录");
      }
    });
  },
};
</script>

<style scoped>
</style>